package cc.monggo.utils;

import org.springframework.beans.factory.annotation.Autowired;

import cc.monggo.utils.encode.EncodeService;
import cc.monggo.utils.encode.impl.EncodeServiceDESImpl;
import cc.monggo.utils.encode.impl.EncodeServiceMD5Impl;

public class EncrypTool {
	@Autowired
	protected static EncodeService encodeService = new EncodeServiceDESImpl();
	private static EncodeService encodeServiceMD5 = new EncodeServiceMD5Impl(); 
	static EncodeService testTool = new EncodeServiceDESImpl();

	/**
	 * DES 加密，可解密
	 * 
	 * @param input
	 * @return
	 */
	public static String encode(String input){
		return encodeService.encode(input); 
	}
	
	/**
	 * DES 解密
	 * 
	 * @param input
	 * @return
	 */
	public static String dencode(String input){
		return encodeService.decode2Str(input); 
		
	}
	
	/**
	 * MD5 加密，用于密码设置
	 * 
	 * @param input
	 * @return
	 */
	public static String encodeMD5(String input){
		return encodeServiceMD5.encode(input);
	}

}
